//package lukeer.fencing.lukeer.fencing.old;
//
//import csproj.fencing.Move;
//import lukeer.fencing.*;
//
//import java.util.ArrayList;
//import java.util.Random;
//
///**
// * Created with IntelliJ IDEA.
// * User: Wafa
// * Date: 07/10/12
// * Time: 14:39
// * To change this template use File | Settings | File Templates.
// */
//public class SimpleEvaluation {
//    private MiniMaxPlayerPruning playerClass;
//    private Random r;
//
//    Piece.Type player;
//    Sector bestSector;
//    ArrayList<Move>  movesToEvaluate; //possible moves in the best sector
//    ArrayList<Sector> sectorsToEvaluate;
//
//
//    public SimpleEvaluation (MiniMaxPlayerPruning playerClass, Board currentState)  {
//        this.playerClass = playerClass;
//        this.r = playerClass.r;
//        movesToEvaluate = new ArrayList<Move>();
//        sectorsToEvaluate = new ArrayList<Sector>();
//        currentState.createSectorArrayList();
//        for (Sector s: currentState.getSectors()){
//            if (!s.isEliminated()) {
//                sectorsToEvaluate.add(s);
//            }
//        }
//    }
//
//    // Find the sector we are most likely to win next
//    public void bestSector (Board b) {
//        int pieceDifference = 0;
//        bestSector = sectorsToEvaluate.get(0);
//        for(Sector s: sectorsToEvaluate) {
//            //System.out.println("a sector to evaluate");
//            int sectorDifference;
//            if(player == Piece.Type.BLACK) sectorDifference = s.getBlack() - s.getWhite();
//            else { sectorDifference = s.getWhite() - s.getWhite();
//            }
//            if(sectorDifference >= pieceDifference) {
//                bestSector = s;
//                pieceDifference = sectorDifference;
//            }
//        }
//        findPossibleMoves(b);
//        sectorsToEvaluate.remove(bestSector);
//    }
//
//    //too many possibility if we put fences randomly in all the board, in which sector start?...
//    private void findPossibleMoves (Board b) {
//        //System.out.println("enter findPossible moves:" + movesToEvaluate.size());
//        ArrayList<Pair> pieces = bestSector.getEmptyPositions();
//        ArrayList<Pair> horiz = b.getEmptyHFences();
//        ArrayList<Pair> vert = b.getEmptyVFences();
//        int p= playerToInt(player);
//        if (!pieces.isEmpty()) {
//            for (Pair piece : pieces) {
//                movesToEvaluate.add(new Move(piece.getX(),piece.getY(),p,true,-1,-1, false, 0));
//                for (Pair hFence : horiz) {
//                    movesToEvaluate.add(new Move(piece.getX(),piece.getY(),p,true,hFence.getX(),hFence.getY(),true, 1));
//                }
//                for (Pair vFence : vert) {
//                    movesToEvaluate.add(new Move(piece.getX(),piece.getY(),p,true,vFence.getX(),vFence.getY(),true, 2));
//                }
//            }
//        }
//        else {
//            for (Pair hFence : horiz) {
//                movesToEvaluate.add(new Move(-1, -1, 0,false, hFence.getX(), hFence.getY(), true, 1));
//            }
//            for (Pair vFence : vert) {
//                movesToEvaluate.add(new Move(-1, -1, 0,false, vFence.getX(), vFence.getY(), true, 2));
//            }
//        }
//        //System.out.println("end findPossible moves:" + movesToEvaluate.size());
//
//    }
//
//    private int playerToInt(Piece.Type p) {
//        if (p == Piece.Type.WHITE)
//            return 1;
//        return 2;
//    }
//
//    public boolean noMoreMoves () {
//        if (sectorsToEvaluate.isEmpty() && movesToEvaluate.isEmpty())
//            return true;
//        return false;
//    }
//
//    public Move nextMove (Board b) {
//        //System.out.println("enter nextMove:   ");
//        if (bestSector == null || movesToEvaluate.isEmpty()) {
//            bestSector(b);
//        }
//        Move m = movesToEvaluate.get(r.nextInt(movesToEvaluate.size()));
//        //System.out.println(m.print());
//        movesToEvaluate.remove(m);
//        return m;
//    }
//
//}
